<?php 

	 //index.php?c=User&a=add
	 //index.php?c=goods&a=delete

	$c = isset($_GET['c'])?$_GET['c']:'Index';
	$a = isset($_GET['a'])?$_GET['a']:'index';

	//自动加载
	if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])){
		define('IS_AJAX',$_SERVER['HTTP_X_REQUESTED_WITH']='XMLHttpRequest');
	}else{
		define('IS_AJAX',false);
	}

	spl_autoload_register('func');

	function func($className){
		if(file_exists('./Model/'.$className.'.php')){
			include './Model/'.$className.'.php';
		}else if(file_exists('./Libs/Page/'.$className.'.php')){
			include './Libs/Page/'.$className.'.php';
		}else if(file_exists('./Libs/'.$className.'.class.php')){
			include './Libs/'.$className.'.class.php';
		}else if(file_exists('./Controller/'.$className.'.php')){
			include './Controller/'.$className.'.php';
		}
	}

	//用M代替new Model
	function M($user)
	{
		return new Model($user);
	}

	//引入类文件
	$demo = $c.'Controller';

	//实例化对象
	$class = new $demo;

	//调用添加的方法
	$class->$a();

 ?>